import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-decal-category',
  templateUrl: './decal-category.component.html',
  styleUrls: ['./decal-category.component.scss']
})
export class DecalCategoryComponent implements OnInit  {
  query = {
    // 当前页
    current: 1,
    // 分页大小
    size: 20,
  };
  listOfData = {
    current: 1,
    total: 100,
    size: 20,
    records: [
      {id: '123', name: '商品名称', price: '87', category: '类型', createTime: '2021-08-10 17:28:00', status: '1'},
      {id: '3425', name: '商品名称22', price: '25', category: '类型44', createTime: '2021-08-10', status: '1'},
    ]
  };
  checked = false;
  setOfCheckedId = new Set();
  indeterminate = false;
  modal = {
    modalVisible: false,
    isAdd: true,
  };
  form = {
    name: null,
    status: 1,
  };

  constructor() {
  }

  ngOnInit(): void {
  }

  queryTableList(): void {
    console.log(this.query, this.setOfCheckedId);
  }

  onPageIndexChange(index: number) {
    console.log(index);
    this.query.current = index;
    // this.checked = false;
    this.queryTableList();
  }

  onPageSizeChange(index: number) {
    console.log(index);
    this.query.current = index;
    // this.checked = false;
    this.queryTableList();
  }


  appendCategory() {
    console.log('添加分类');
    this.modal.modalVisible = true;
    this.modal.isAdd = true;
  }

  edit(data: any) {
    console.log(data, '编辑');
    this.modal.modalVisible = true;
    this.modal.isAdd = false;
  }

  // 模态框取消按钮监听
  handleModalCancel() {
    this.modal.modalVisible = false;
    this.resetFormData();
  }

  // 模态框确认按钮监听
  handleModalOk() {
    this.modal.modalVisible = false;
    this.resetFormData();
  }

  // 重置数据
  resetFormData() {
    this.form = {
      name: null,
      status: 1,
    };
  }

  deleteRow(id: any) {
    console.log('删除行', id);
  }
}
